package cn.jisol.ngame.client;

import cn.jisol.ngame.network.entity.JNetParam;
import com.google.protobuf.AbstractMessage;
import lombok.Getter;
import lombok.Setter;
import org.apache.catalina.User;

import javax.websocket.Session;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Objects;

@Getter
@Setter
public abstract class NClient {

    private String id;

    public NClient(String id){
        this.id = id;
    }

    //调用数据
    public void invoke(int hId){
        this.invoke(hId,null);
    }
    public void invoke(int hId, AbstractMessage data){
        this.invoke(0,hId,data);
    }
    public void invoke(int id,int hId, AbstractMessage data){
        this.onSendMessage(JNetParam.encoder(id,hId,data));
    }

    //发送数据包
    public abstract void onSendMessage(byte[] bytes);

    //关闭连接
    public abstract void Close();

    //是否连接中
    public abstract  boolean isOpen();

}
